<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	String _db = user.getDbType();
	Map<String,List<Map<String, String>>> dicMap = user.getDicMap();
	List<Map<String, String>> list = null;
	String temp = "";
	
	String tbe_marital_status = "";//婚姻状态
	String tbe_birth_control_measures = "";//节育措施
	String tbe_es_reason="";//重点理由
	
	list = dicMap.get("27");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_marital_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("104");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_birth_control_measures += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("107");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_es_reason += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>"/>
		<title>重点服务对象信息服务</title>
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>
		
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.validate.min.js" ></script> 
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.metadata.js"></script>
		<script type="text/javascript" src="ligerUI/jquery-validation/messages_cn.js" ></script>
		
<script type="text/javascript">
var _db = '<%=_db%>';
_jsonObj.classname = "com.wxtf.platform.main.keyserobj.KeySet";
_jsonObj.methodname = "queryPage";
_jsonObj.logicdata = "[{\"types\":\"init\"}]";

var manager;//人员表格
$(function(){
	manager = $("#emp-grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',
		usePager: true, rownumbers: true, checkbox: false , alternatingRow: true,
		columns: [		    
			
		    { display: '是否重点服务对象', name: 'tbe_is_es', width: 130 ,        
				render: function (row)
                    {
                       var html='<font color="red">否</font>';
                       if(row.tbe_is_es=='0'){
                       		html = '<font color="red">否</font>';
                       }else if(row.tbe_is_es=='1'){
                       		html = '<font color="green">是</font>';
                       }
                       return html;
                    }
			},
			{ display: 'tbe_id', name: 'tbe_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '机构名称', name: 'reserve1', width:1,hide: true },
			{ display: '职工证号', name: 'tbe_work_permit', width: 1,hide: true },  
			{ display: '用工形式', name: 'tbe_employment_forms', width:  1, hide:true },
			{ display: '姓名', name: 'tbe_name', width: 100,
			      render: function(record, index, value, oth){
					return ' <a href="javascript:bianji(\''+record.tbe_id+'\',\'' + record.tbe_name + '\',\'' + record.tbe_is_es + '\',\''+record.tbe_es_reason+'\',\''+record.tbe_es_time+'\',\''+record.tbe_birth_control_measures+'\',\''+record.tbfi_children_num+'\')">'+ value+'</a>';
				}
			 },
            { display: '身份证号', name: 'tbe_idcard', width: 180 },
			{ display: '曾用名', name: 'tbe_former_name', width: 1,  hide: true },
			{ display: '拼音码', name: 'tbe_spell_code', width: 1, hide: true },
			{ display: '性别', name: 'tbe_sex', width: 40},
			{ display: '设为重点时间', name: 'tbe_es_time', width:  100 },
			{ display: '出生日期', name: 'tbe_birthday', width: 100 },   
			{ display: '年龄', name: 'tbe_age', width:1,  hide: true  }, 
			{ display: '籍贯', name: 'tbe_native_palce', width: 1,  hide: true},
			{ display: '民族', name: 'tbe_nation', width:  80 ,
			    render: function(record, index, value, oth){
					<%
					list = dicMap.get("5");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}
			},    
			{ display: '出生地', name: 'tbe_birthplace', width:  1, hide:true },
			{ display: '入厂时间', name: 'tbe_join_time', width:  1, hide:true },
			{ display: '工龄', name: 'tbe_seniority', width:  1, hide:true },
			{ display: '手机', name: 'tbe_mobile', width: 1,  hide: true},
			{ display: '家庭电话', name: 'tbe_family_phone', width: 1,  hide: true },
			{ display: '家庭住址', name: 'tbe_address', width: 1,  hide: true },
			{ display: '婚姻状态', name: 'tbe_marital_status', width: 90,   
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("27");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}
			},
			{ display: '结婚时间', name: 'tbe_married_time', width:  1, hide:true },
			{ display: '结婚证号', name: 'tbe_marriage_certificate', width:  1, hide:true },
			{ display: '政治面貌', name: 'tbe_political_status', width:  1, hide:true },
			{ display: '学历', name: 'tbe_qualification', width:  1, hide:true },
			{ display: '毕业学校', name: 'tbe_graduate_college', width:  1, hide:true },
			{ display: '所学专业', name: 'tbe_major', width:  1, hide:true },
			{ display: '工作时间', name: 'tbe_work_area', width:  1, hide:true },
			{ display: '职务', name: 'tbe_position', width:  1, hide:true },
			{ display: '子女数', name: 'tbfi_children_num', width: 60},      			
			{ display: '是否允许再生育', name: 'tbe_is_again_birth', width:  120 ,  
			         render: function (row)
                    {
                       var html='<font color="red">否</font>';
                       if(row.tbe_is_again_birth=='0'){
                       		html = '<font color="red">否</font>';
                       }else if(row.tbe_is_again_birth=='1'){
                       		html = '<font color="green">是</font>';
                       }
                       return html;
                    }}, 
			{ display: '是否不孕症（绝经）', name: 'tbe_is_barrenness', width:  150,   
				render: function (row)
                    {
                       var html='<font color="red">否</font>';
                       if(row.tbe_is_barrenness=='0'){
                       		html = '<font color="red">否</font>';
                       }else if(row.tbe_is_barrenness=='1'){
                       		html = '<font color="green">是</font>';
                       }
                       return html;
                    } 
              },   
			{ display: '是否晚婚', name: 'tbe_is_late_marriage', width:  1, hide:true },
			{ display: '是否晚育', name: 'tbe_is_late_birth', width:  1, hide:true },
			{ display: '员工状态', name: 'tbe_status', width:  1, hide:true },
			{ display: '生育能力状态', name: 'tbe_ba_status', width:  1, hide:true },
			{ display:'节育措施', name:'tbe_birth_control_measures',id:'tbe_birth_control_measures',align: 'center',width: 110,
	            render: function(record, index, value, oth){
					<%
					list = dicMap.get("104");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}},			
			{ display: '重点理由', name: 'tbe_es_reason', width:  200,
			   render: function(record, index, value, oth){
					<%
					list = dicMap.get("107");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					if(record.tbe_es_reason=="0"){value="无";}
					return value;
				}
			  },
			{ display: '子女情况', name: 'tbe_children_status', width:  1, hide:true },			
			{ display: '排序号', name: 'tbe_order', width:  1, hide:true },
			{ display: '备注', name: 'tbe_memo', width:  1, hide:true },
			{ display: 'reserve2', name: 'reserve2', width:  1, hide:true },
			{ display: 'reserve3', name: 'reserve3', width:  1, hide:true },
			{ display: 'reserve4', name: 'reserve4', width:  1, hide:true },
			{ display: 'reserve5', name: 'reserve5', width:  1, hide:true },
			{ display: '录入人', name: 'create_by', width:  1, hide:true },
			{ display: '录入时间', name: 'create_time', width:  1, hide:true },
			{ display: '最后修改人', name: 'last_modify_by', width:  1, hide:true },
			{ display: '最后修改时间', name: 'last_modify_time', width: 1, hide:true }	,
			{ display: '设为重点',isSort:false,name:'edit',width:80,render:function(record, index, value, oth){
	               			if(record.tbe_id!="0"){
	              				return '<a href="javascript:bianji(\''+record.tbe_id+'\',\'' + record.tbe_name + '\',\'' + record.tbe_is_es + '\',\''+record.tbe_es_reason+'\',\''+record.tbe_es_time+'\',\''+record.tbe_birth_control_measures+'\',\''+record.tbfi_children_num+'\')"  class="edit_btn_div" onmouseover="this.className=\'edit_btn_div_over\'" onmouseout="this.className=\'edit_btn_div\'"><img src="ligerUI/skins/icons/edit.gif"/></div>';
	              			}
	               		}
	        }		
		]			
	});
});

        //打开窗口
       	var win;        
        function f_openWindow(target, title, width, height, func, func2) {
			if(win==null){
            	win = initWindowByDiv(target, title, width, height, func, func2);
			}else{
				win.show();
			}
       	}
       	
       	function editAll(){
			document.forms[0].reset();
			var param = { 
				"classname": "com.wxtf.platform.main.keyserobj.KeySet",
				"methodname": "update",
				"logicdata": "[]",
				"extenddata": "[]"
			};
		    f_openWindow('setkey', '设置重点服务对象', 350, 200 ,function()
		    {					
					var tbe_id = $("#tbe_id").val();
					var tbe_is_es = $(":radio[name='key_marked']:checked").val();
					var tbe_children_num = $("#tbe_children_num").val();
					param.logicdata = '[{"tbe_id":"'+tbe_id+'","tbe_is_es":"'+tbe_is_es+'","tbe_children_num":"'+tbe_children_num+'"}]';
					callserver(param,function(data, satus){
						if(data.result || data.result == 'true'){
							succMsgTip(data.resultrecord);
						}else{
							warningTip(data.resultrecord);
						}
						reload();
						win.hide();
					},function(data, satus){
						warningTip(data.resultrecord);
					});
			}, 
			function()
			{
				win.hide();
			}
			);
		}
	   
//节育措施
function getDicNameById_tbe_birth_control_measures(id){
	<%
	list = dicMap.get("104");
	temp = "";
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
	%>
	if(id == '<%=map.get("tmgd_id")%>'){
		<%temp = map.get("tmgd_name");%>
		return '<%=temp%>';
	}
	<%}}%>
	return id;
}
	   
       function bianji(tbe_id,tbe_name,tbe_is_es,tbe_es_reason,tbe_es_time,tbe_birth_control_measures,tbfi_children_num){
			document.forms[0].reset();
			$("#tbe_es_time").ligerDateEditor({ format: "yyyy-MM-dd", width:182 });
			$("#tbe_id").val(tbe_id);
			$("#u_name").val(tbe_name);
			$(":radio[name='key_marked'][value='"+tbe_is_es+"']").attr("checked", true);
			$("#tbe_es_reason").val(tbe_es_reason);
			$("#tbe_es_time").val(tbe_es_time);
			$("#tbe_birth_control_measures").val(getDicNameById_tbe_birth_control_measures(tbe_birth_control_measures));
			$("#tbfi_children_num").val(tbfi_children_num);
			var param = { 
				"classname": "com.wxtf.platform.main.keyserobj.KeySet",
				"methodname": "update",
				"logicdata": "[]",
				"extenddata": "[]"
			};		
			f_openWindow('setkey', '设置重点服务对象', 370, 250 ,function()
		    {					
					var tbe_id = $("#tbe_id").val();
					var tbe_is_es = $(":radio[name='key_marked']:checked").val();
					var tbfi_children_num = $("#tbfi_children_num").val();
					var org_id = $("#org_id").val();
					var tbe_es_reason = $("#tbe_es_reason").val();
					var tbe_es_time = $("#tbe_es_time").val();
					var tbe_birth_control_measures = $("#tbe_birth_control_measures").val();
					
					if(tbe_is_es=='1')
					{
					   if(tbe_es_time==''||tbe_es_time==" "||tbe_es_time==null){
						warningTip("请输入重点时间！");
						return;
						}
					}
					
					param.logicdata = '[{"tbe_id":"'+tbe_id+'","tbe_is_es":"'+tbe_is_es+'","tbfi_children_num":"'+tbfi_children_num+'","org_id":"'+org_id+'","tbe_es_reason":"'+tbe_es_reason+'","tbe_birth_control_measures":"'+tbe_birth_control_measures+'","tbe_es_time":"'+tbe_es_time+'"}]';
					callserver(param,function(data, satus){
						if(data.result || data.result == 'true'){
							succMsgTip(data.resultrecord);
						}else{
							warningTip(data.resultrecord);
						}
						reload();
						win.hide();
					},function(data, satus){
						warningTip(data.resultrecord);
					});
			}, 
			function()
			{
				win.hide();
			}
			);
		}

		/*
 		* 表格刷新
		 */
		function reload(){
			_jsonObj.methodname = "queryPage";
			_jsonObj.logicdata = "[{\"types\":\"init\"}]";
			manager.loadData();
		}

/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	if(win){
		win.hide();
	}
	succMsgTip(data.resultrecord);
	reload();
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	succMsgTip(data.resultrecord);
}

/*
 * 获取列表选中的人员ID
 */
function getUserIds(){
	var arrayUsers = manager.getSelecteds();
	if(arrayUsers.length == 0){
		return "";
	} else {
		var text = "";
		for(var i=0; i<arrayUsers.length; i++){
			text += arrayUsers[i].tbe_id + ",";
		}
		return text.substring(0, text.length - 1);
	}
}

/*
 * 重置-条件查询
 */
function serReset(){
	// $('#ser_org').val('');
	$('#ser_name').val('');
	$('#ser_idcard').val('');
	$('#ser_tbe_is_es').val('');
	$('#ser_tbe_es_reason').val(''); //用工形式
	$('#ser_tbe_birth_control_measures').val(''); 
}

/*
 * 条件查询
 */
function serch1(){
	var orgIds = $('#ser_org').val();
	var tbe_name = $('#ser_name').val();
	var tbe_idcard = $('#ser_idcard').val();
	var tbe_is_es = $('#ser_tbe_is_es').val();
	var tbe_es_reason = $('#ser_tbe_es_reason').val();
	var tbe_birth_control_measures = $('#ser_tbe_birth_control_measures').val();
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbe_is_es\":\"' + tbe_is_es
			+ '\",\"tbe_es_reason\":\"' + tbe_es_reason + '\",\"tbe_name\":\"' + tbe_name
			+ '\",\"tbe_birth_control_measures\":\"' + tbe_birth_control_measures + '\",\"tbe_idcard\":\"' + tbe_idcard
			+ '\",\"types\":\"serch1\"}]';
	manager.loadData();
}


 /*
 * 导出
 */
function expData(){
	var orgIds = $('#ser_org').val();
	var tbe_name = $('#ser_name').val().trim();
	var tbe_idcard = $('#ser_idcard').val().trim();
	var tbe_is_es = $('#ser_tbe_is_es').val();
	var tbe_es_reason = $('#ser_tbe_es_reason').val();
	var tbe_birth_control_measures = $('#ser_tbe_birth_control_measures').val();

	_jsonObj.methodname = "expData";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbe_name\":\"' + tbe_name + '\",\"tbe_idcard\":\"' + tbe_idcard + '\",\"tbe_is_es\":\"' + tbe_is_es + '\",\"tbe_es_reason\":\"' + tbe_es_reason + '\",\"tbe_birth_control_measures\":\"' + tbe_birth_control_measures + '\"}]';
	
	callserver(_jsonObj, function(data, textStatus){
		if(data.result){
			parent.downloadFile(data.resultrecord);
		} else {
			warningTip(data.resultrecord);
		}
	}, function(data, textStatus){
	    warningTip(data.resultrecord);
	});
}


</script>
</head>
	<body>
		<table id="aaa" class="serTable">
			<tr>
                <td>
					机构：<select id="ser_org" style=" width: 160px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>
                <td>
					重点理由：<select id="ser_tbe_es_reason" style=" width: 160px;">
						<option value="null"></option>
						<%=tbe_es_reason%>
					</select>
				</td>
                <td>姓名：<input id="ser_name" style=" width: 160px;"/></td>
				<td><input class="btn2" value="搜索" type="button" onclick="serch1();" /></td>
				<td></td>
			</tr>
			<tr>
				<td>是否重点：<select id="ser_tbe_is_es" style=" width: 160px;">
						<option value="null"></option>
						<option value="0">否</option>
						<option value="1">是</option>
					</select>
				</td>
				<td>节育措施：<select id="ser_tbe_birth_control_measures" style=" width: 160px;">
						<option value="null"></option>
						<%=tbe_birth_control_measures%>
					</select></td>
				<td>身份证：<input id="ser_idcard" style=" width: 160px;"/></td>
				<td><input class="btn2" value="重置" type="button" onclick="serReset();" /></td>
			    <td><input class="btn2" value="导出" type="button" onclick="expData();" /></td>
			</tr>
		</table>
		
		<div id="emp-grid"></div>
			
		<div id="setkey" style="display:none;" >
			<form id="setkeyForm" >
			    <input type="hidden" id="tbe_id" name="tbe_id" value="" />
				<input type="hidden" id="org_id" name="org_id" value="" />
				<input type="hidden" id="reserve1" name="reserve1" value="" />
				<input type="hidden" id="reserve2" name="reserve2" value="" />
				<input type="hidden" id="reserve3" name="reserve3" value="" />
				<input type="hidden" id="reserve4" name="reserve4" value="" />
				<input type="hidden" id="reserve5" name="reserve5" value="" />
				<input type="hidden" id="create_by" name="create_by" value="" />
				<input type="hidden" id="create_time" name="create_time" value="" />
				<input type="hidden" id="last_modify_by" name="last_modify_by" value="" />
				<input type="hidden" id="last_modify_time" name="last_modify_time" value="" />
				<table class="form_table" >
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight:bold;height: 28px; line-height: 28px;margin: 0 0 5px;" >
								<img src="ligerUI/skins/icons/communication.gif"/>
								<span>设置重点服务对象</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label" style=" width: 160px;">姓名： </td>
						<td>
						 <input  id="u_name" name="u_name" value="" disabled="disabled" style="width:182px;"/>
					    </td>
					    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					</tr>
					<tr>
						<td class="form_label" style=" width: 160px;">是否设为重点： </td>
						<td align="left">
						    <input type="radio" name="key_marked" value="1" />是
							<input type="radio" name="key_marked" value="0" />否
					    </td>
					    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					</tr>
					<tr>
					    <td class="form_label">重点理由： </td>
					    <td >
					    		<select id="tbe_es_reason" name="tbe_es_reason" style=" width: 182px; margin-left: 1px;">
						            <option value="0">-- 无 --</option>
						            <%=tbe_es_reason%>
						        </select>
						</td>
						<td></td>
					</tr>
					<tr>
					    <td class="form_label">设为重点时间： </td>
					    <td><input  id="tbe_es_time" name="tbe_es_time" style="width:182px;" onkeyup="this.value=formatdata(this.value);" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
					    <td><font color="red">*</font></td>
					</tr>
					<tr>
					    <td class="form_label">节育措施： </td>
					    <td>
						    <input  id="tbe_birth_control_measures" name="tbe_birth_control_measures" value="" disabled="disabled" style="width:182px;"/>
						</td>
						<td></td>
					</tr>
					<tr>
					    <td class="form_label" >子女数： </td>
					    <td>
							<input  id="tbfi_children_num" name="tbfi_children_num" value="" disabled="disabled" style="width:182px;"/>
				        </td>
				        <td></td>
					</tr>
				</table>
			</form>			
		</div>
			
	</body>
</html>
